﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace hzWeb
{
   public class Config
    {
       private static Config config;
       private static object lockOjbect = new object();
       public static string webUrl = "http://sharepoint2010/";
       public static Config Instance {
           get 
           {
               lock (lockOjbect)
               {
                   if (null == config)
                   {                      
                        config = new Config();                          
                        XmlDocument xmlDoc = new XmlDocument();
                        // SPFile file = spWeb.RootWeb.GetFile("/_LAYOUTS/hzWeb/ChatRoomConfig.xml");
                        string xmlPath = SPUtility.GetGenericSetupPath("") + "\\TEMPLATE\\LAYOUTS\\hzWeb\\ChatRoomConfig.xml";
                        xmlDoc.Load(xmlPath);
                        config.adminGroupsPath = xmlDoc.GetElementsByTagName("AdminGroupsPath")[0].InnerText;
                        config.memberGroupPath = xmlDoc.GetElementsByTagName("MemberGroupPath")[0].InnerText;
                        config.persistentChatPool = xmlDoc.GetElementsByTagName("PersistentChatPool")[0].InnerText;
                        config.persistentChatRoomCategory = xmlDoc.GetElementsByTagName("PersistentChatRoomCategory")[0].InnerText;
                        config.meetingRoomServiceUrl = xmlDoc.GetElementsByTagName("MeetingRoomServiceUrl")[0].InnerText;
                        config.chatRoomServiceUrl = xmlDoc.GetElementsByTagName("ChatRoomServiceUrl")[0].InnerText;
                        config.userNameForCreatingMeetingRoom = xmlDoc.GetElementsByTagName("UserNameForCreatingMeetingRoom")[0].InnerText;
                        config.passwordForCreatingMeetingRoom = xmlDoc.GetElementsByTagName("PasswordForCreatingMeetingRoom")[0].InnerText;
                        config.sipForCreatingMeetingRoom = xmlDoc.GetElementsByTagName("SipForCreatingMeetingRoom")[0].InnerText;
                        config.lyncServer = xmlDoc.GetElementsByTagName("LyncServer")[0].InnerText;
                        config.domainName = xmlDoc.GetElementsByTagName("DomainName")[0].InnerText;
                        config.chatRoomOU = xmlDoc.GetElementsByTagName("ChatRoomOU")[0].InnerText;
                        config.supperAdminGroup = xmlDoc.GetElementsByTagName("SupperAdminGroup")[0].InnerText;
                       // SupperAdminGroup
                        config.meetingRoomURLPrefix = xmlDoc.GetElementsByTagName("MeetingRoomURLPrefix")[0].InnerText;
                   }
               }

              return config;
           }
       }

       public string adminGroupsPath = "CN=PCRoomManager统一通讯组,OU=chatroom,DC=ITFirst,DC=com";
       public string memberGroupPath = "CN=PCRoomMembers统一通讯组,OU=chatroom,DC=ITFirst,DC=com";
       public string persistentChatPool = "management.itfirst.com";
       public string persistentChatRoomCategory = "TestChatRoom001";
       public string meetingRoomServiceUrl = "http://vdi.itfirst.com:8888/MeetingRoomService.svc";
       public string chatRoomServiceUrl = "http://lync:8888/chatRoomService/chatRoomService.svc";
       public string userNameForCreatingMeetingRoom = "test2";
       public string passwordForCreatingMeetingRoom = "Password01!";
       public string sipForCreatingMeetingRoom = "sip:test2@itfirst.com";
       public string lyncServer = "LYNC.ITFIRST.COM";
       public string domainName = "itfirst.com";
       public string chatRoomOU = "OU=PersistentChatGroup,DC=ITFirst,DC=com";
       public string supperAdminGroup = "ITFirst\\SHACPersistentChatAdmins";
       public string meetingRoomURLPrefix = "meet";
    }
}
